<template>
  <el-tabs v-model="activeName">
    <el-tab-pane label="发布的帖子" name="first">
      <SubMoment v-if="subMomentList.length>0" :momentList="subMomentList" />
      <div v-else>没有发布过帖子~</div>
    </el-tab-pane>
    <el-tab-pane label="回复的帖子" name="second">
      <ReplyList v-if="replyList.length > 0" :replyList="replyList" />
      <div v-else>没有回复过帖子~</div>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import SubMoment from '../../components/SubMoment.vue'
import ReplyList from '../../components/ReplyList.vue'
import passTime from '../../utils/passTime'
import getDate from '../../utils/computeDay'
export default {
  data () {
    return {
      activeName: 'first',
      subMomentList: [],
      replyList: []
    }
  },
  components: {
    SubMoment,
    ReplyList
  },
  methods: {
    async getSubMoment () {
      const {id: userId} = JSON.parse(window.sessionStorage.getItem('userInfo'))
      const {data: res} = await this.$http.get(`/moment/subMoment/${userId}`)
      this.subMomentList = res
      this.passTime(this.subMomentList[0].createAt)
    },
    async getReplyMoment () {
      const {data: res} = await this.$http.get('/moment/replyMoment')
      this.replyList = res
    },
    passTime: passTime,
    getDate
  },
  created () {
    this.getSubMoment()
    this.getReplyMoment()
    console.log(passTime('2022-01-18 22:59:44'), 'pppp')
    // const loginDay = moment(Date.now()).format('YYYY-MM-DD')
    console.log(this.getDate('2022-02-02', 0))
  },
  mounted () {
    this.$bus.$emit('profile', 3)
  }
}
</script>

<style scoped lang="less">
  /deep/ .el-tabs__header {
    padding-left: 10px;
  }
</style>
